// 获取本地缓存
const getStorage = (name) => {
    const data = JSON.parse(sessionStorage.getItem(name))
    return data
}

// 设置本地缓存
const setStorage = (name, data) => {
    if (Object.prototype.toString.call(data) === '[object Object]') {
        sessionStorage.setItem(name, JSON.stringify(data))
    } else {
        new Error('数据类型错误')
    }

}

// 清除对应键名本地缓存
const removeStorage = (name) => {
    sessionStorage.removeItem(name)
}

// 注销登录
const clearStorage = () => {
    sessionStorage.clear()
}

module.exports = {
    getStorage,
    setStorage,
    removeStorage,
    clearStorage
}